<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<?php

$xml=simplexml_load_file("C:\wamp\www\uploaddata.xml");

$isName = TRUE;
$isEmail = FALSE;
$isAddress = TRUE;
$isCity = FALSE;
$isTelephone = FALSE;

$dataFilterKey = "";
$i = 0;

$strName = "";
$strAddress = "";
$strTelephone = "";
$strCity ="";
$strEmail ="";


$xml=simplexml_load_file("upxml.xml");

foreach($xml->children() as $xml1)
{
	
	foreach($xml1->children() as $child)
  	{
		if($child->getName() == "name")
			$strName = $child;
			if($child->getName() == "address")
			$strAddress = $child;
			if($child->getName() == "telephone")
			$strTelephone = $child;
			if($child->getName() == "email")
			$strEmail = $child;
			if($child->getName() == "city")
			$strCity = $child;
			
			
  	}
	if ( $isName OR $isAddress OR $isTelephone OR $isEmail OR $isCity )
	{
			if($isName)
			$dataFilterKey = $dataFilterKey . $strName;
			if($isAddress)
			$dataFilterKey = $dataFilterKey . $strAddress;
			if($isTelephone)
			$dataFilterKey = $dataFilterKey . $strTelephone;
			if($isEmail)
			$dataFilterKey = $dataFilterKey . $strEmail;
			if($isCity)
			$dataFilterKey = $dataFilterKey . $strCity;
			
			//print "key is " . $dataFilterKey . "<br>";
			$dataArray[$dataFilterKey]["name"] = $strName;
			$dataArray[$dataFilterKey]["address"] = $strAddress; 
			$dataArray[$dataFilterKey]["telephone"] = $strTelephone; 
			$dataArray[$dataFilterKey]["email"] = $strEmail; 
			$dataArray[$dataFilterKey]["city"] = $strCity; 
			$dataFilterKey = "";
	}else
	{
					//print "key is " . $dataFilterKey . "<br>";
			$dataArray[$i]["name"] = $strName;
			$dataArray[$i]["address"] = $strAddress; 
			$dataArray[$i]["telephone"] = $strTelephone; 
			$dataArray[$i]["email"] = $strEmail; 
			$dataArray[$i]["city"] = $strCity; 
			$i++;
	}
	

if ( $isName OR $isAddress OR $isTelephone OR $isEmail OR $isCity )
{
	foreach($dataArray as $x=>$x_value)
   		{

			   echo $dataArray[$x]["name"] . "\t" . $dataArray[$x]["address"] ."\t". $dataArray[$x]["telephone"] ."\t". $dataArray[$x]["email"] ."\t". $dataArray[$x]["city"] . "<br>";
   		}
} else
{
	$arrlength=count($dataArray);

	for($x=0;$x<$arrlength;$x++)
  	{
  			echo $dataArray[$x]["name"] . "\t" . $dataArray[$x]["address"] ."\t". $dataArray[$x]["telephone"] ."\t". $dataArray[$x]["email"] ."\t". $dataArray[$x]["city"] . "<br>";
  }
}
}
?>


</body>
</html>